package aapilast3;
import reflect.Teacher;

import java.lang.reflect.Field;

public class ReflectDemo8 {
    public static void main(String[] args) throws Exception {
        Teacher teacher = new Teacher();
        teacher.setName("张三");
        System.out.println(teacher);

        Class<?> cls = Class.forName("reflect.Teacher");
        Object obj = cls.newInstance();

        Field field = cls.getDeclaredField("name");
        field.setAccessible(true);
        System.out.println(field.getName());
        field.set(obj, "李四");
        System.out.println(obj);
    }
}
